package com.forum.common.event;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
 * 帖子审核事件
 */
@Getter
@Setter
@NoArgsConstructor
public class PostAuditEvent extends MessageEvent {
    
    /**
     * 帖子标题
     */
    private String postTitle;
    
    /**
     * 审核状态
     */
    private PostAuditStatus status;
    
    /**
     * 审核备注
     */
    private String remark;
    
    /**
     * 构造一个帖子审核通过事件
     * 
     * @param senderId 审核人ID
     * @param receiverId 帖子作者ID
     * @param resourceId 帖子ID
     * @param postTitle 帖子标题
     * @param remark 审核备注
     * @return 帖子审核通过事件
     */
    public static PostAuditEvent approved(Long senderId, Long receiverId, Long resourceId, String postTitle, String remark) {
        PostAuditEvent event = new PostAuditEvent();
        event.setType(EventType.POST_AUDIT_APPROVED);
        event.setSenderId(senderId);
        event.setReceiverId(receiverId);
        event.setResourceId(resourceId);
        event.setPostTitle(postTitle);
        event.setContent("您的帖子《" + postTitle + "》已审核通过");
        event.setStatus(PostAuditStatus.APPROVED);
        event.setRemark(remark);
        event.setResourceType("POST");
        // 假设帖子详情页面的路由
        event.setLink("/post/detail/" + resourceId);
        return event;
    }
    
    /**
     * 构造一个帖子审核拒绝事件
     * 
     * @param senderId 审核人ID
     * @param receiverId 帖子作者ID
     * @param resourceId 帖子ID
     * @param postTitle 帖子标题
     * @param remark 拒绝原因
     * @return 帖子审核拒绝事件
     */
    public static PostAuditEvent rejected(Long senderId, Long receiverId, Long resourceId, String postTitle, String remark) {
        PostAuditEvent event = new PostAuditEvent();
        event.setType(EventType.POST_AUDIT_REJECTED);
        event.setSenderId(senderId);
        event.setReceiverId(receiverId);
        event.setResourceId(resourceId);
        event.setPostTitle(postTitle);
        event.setContent("您的帖子《" + postTitle + "》审核未通过，原因：" + remark);
        event.setStatus(PostAuditStatus.REJECTED);
        event.setRemark(remark);
        event.setResourceType("POST");
        // 假设用户的帖子管理页面路由
        event.setLink("/user/posts");
        return event;
    }
    
    /**
     * 帖子审核状态枚举
     */
    public enum PostAuditStatus {
        /**
         * 审核通过
         */
        APPROVED,
        
        /**
         * 审核拒绝
         */
        REJECTED
    }
} 